<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: include/hardware/sync.h Source File</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.1.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('rp2__common_2hardware__sync_2include_2hardware_2sync_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">sync.h</div></div>
</div><!--header-->
<div class="contents">
<a href="rp2__common_2hardware__sync_2include_2hardware_2sync_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> */</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#ifndef _HARDWARE_SYNC_H</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#define _HARDWARE_SYNC_H</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;<a class="code" href="pico_8h.html">pico.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#include &quot;<a class="code" href="address__mapped_8h.html">hardware/address_mapped.h</a>&quot;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span> </div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="preprocessor">#include &quot;<a class="code" href="hazard3_8h.html">hardware/hazard3.h</a>&quot;</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span> </div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span> </div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span><span class="comment">// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_SYNC, Enable/disable assertions in the hardware_sync module, type=bool, default=0, group=hardware_sync</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span><span class="preprocessor">#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_SYNC</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span><span class="preprocessor">#ifdef PARAM_ASSERTIONS_ENABLED_SYNC </span><span class="comment">// backwards compatibility with SDK &lt; 2.0.0</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span><span class="preprocessor">#define PARAM_ASSERTIONS_ENABLED_HARDWARE_SYNC PARAM_ASSERTIONS_ENABLED_SYNC</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span><span class="preprocessor">#define PARAM_ASSERTIONS_ENABLED_HARDWARE_SYNC 0</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span> </div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga9442d73d817ec600c67a632edf8c6668">   71</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga9442d73d817ec600c67a632edf8c6668">__nop</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span><span class="preprocessor">#if !__ARM_ARCH_6M__</span></div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>    __asm <span class="keyword">volatile</span> (<span class="stringliteral">&quot;nop&quot;</span>);</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>    __asm <span class="keyword">volatile</span> (<span class="stringliteral">&quot;nop.w&quot;</span>);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>    __asm <span class="keyword">volatile</span> (<span class="stringliteral">&quot;nop&quot;</span>);</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>}</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span> </div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span> </div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span><span class="preprocessor">#if !__has_builtin(__sev)</span></div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga486eada32246494118f8273a80ae6856">   90</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga486eada32246494118f8273a80ae6856">__sev</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span>    __hazard3_unblock();</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    pico_default_asm_volatile (<span class="stringliteral">&quot;sev&quot;</span>);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>}</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span> </div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span><span class="preprocessor">#if !__has_builtin(__wfe)</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga7799a0b9fc6444d463170266392f5fcd">  106</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga7799a0b9fc6444d463170266392f5fcd">__wfe</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>    __hazard3_block();</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span>    pico_default_asm_volatile (<span class="stringliteral">&quot;wfe&quot;</span>);</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span>}</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span> </div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span><span class="preprocessor">#if !__has_builtin(__wfi)</span></div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#gaaf83973c85c4d0987d34f31ff9590ec5">  121</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#gaaf83973c85c4d0987d34f31ff9590ec5">__wfi</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>    pico_default_asm_volatile(<span class="stringliteral">&quot;wfi&quot;</span>);</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span>}</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span> </div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga577b1aba04c5e961c151c2b5d116618d">  132</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga577b1aba04c5e961c151c2b5d116618d">__dmb</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>    __asm <span class="keyword">volatile</span> (<span class="stringliteral">&quot;fence rw, rw&quot;</span> : : : <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>    pico_default_asm_volatile (<span class="stringliteral">&quot;dmb&quot;</span> : : : <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span>}</div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno">  139</span> </div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#gaf9544395481cc10fe75df2e8fe58d52a">  147</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#gaf9544395481cc10fe75df2e8fe58d52a">__dsb</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>    __asm <span class="keyword">volatile</span> (<span class="stringliteral">&quot;fence rw, rw&quot;</span> : : : <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>    pico_default_asm_volatile (<span class="stringliteral">&quot;dsb&quot;</span> : : : <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>}</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span> </div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#gae516e592b0d308fe5b032e34109b0057">  162</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#gae516e592b0d308fe5b032e34109b0057">__isb</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span>    __asm <span class="keyword">volatile</span> (<span class="stringliteral">&quot;fence.i&quot;</span> : : : <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span>    pico_default_asm_volatile(<span class="stringliteral">&quot;isb&quot;</span> ::: <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span>}</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span> </div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#gaac3457fdba1624e5f45e7f936ad68049">  173</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#gaac3457fdba1624e5f45e7f936ad68049">__mem_fence_acquire</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span>    <span class="comment">// the original code below makes it hard for us to be included from C++ via a header</span></div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno">  175</span>    <span class="comment">// which itself is in an extern &quot;C&quot;, so just use __dmb instead, which is what</span></div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno">  176</span>    <span class="comment">// is required on Cortex M0+</span></div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno">  177</span>    <a class="code hl_function" href="group__hardware__sync.html#ga577b1aba04c5e961c151c2b5d116618d">__dmb</a>();</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno">  178</span><span class="comment">//#ifndef __cplusplus</span></div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno">  179</span><span class="comment">//    atomic_thread_fence(memory_order_acquire);</span></div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno">  180</span><span class="comment">//#else</span></div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno">  181</span><span class="comment">//    std::atomic_thread_fence(std::memory_order_acquire);</span></div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno">  182</span><span class="comment">//#endif</span></div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno">  183</span>}</div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno">  184</span> </div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga1a9f3cba87fe49a3907a1535b9adfa3f">  189</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga1a9f3cba87fe49a3907a1535b9adfa3f">__mem_fence_release</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span>    <span class="comment">// the original code below makes it hard for us to be included from C++ via a header</span></div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span>    <span class="comment">// which itself is in an extern &quot;C&quot;, so just use __dmb instead, which is what</span></div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno">  192</span>    <span class="comment">// is required on Cortex M0+</span></div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span>    <a class="code hl_function" href="group__hardware__sync.html#ga577b1aba04c5e961c151c2b5d116618d">__dmb</a>();</div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span><span class="comment">//#ifndef __cplusplus</span></div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno">  195</span><span class="comment">//    atomic_thread_fence(memory_order_release);</span></div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span><span class="comment">//#else</span></div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span><span class="comment">//    std::atomic_thread_fence(std::memory_order_release);</span></div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno">  198</span><span class="comment">//#endif</span></div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>}</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span> </div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga15ada9cfb92615e5bb05a29aa3fc7ad8">  206</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> uint32_t <a class="code hl_function" href="group__hardware__sync.html#ga15ada9cfb92615e5bb05a29aa3fc7ad8">save_and_disable_interrupts</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno">  207</span>    uint32_t status;</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno">  208</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno">  209</span>    pico_default_asm_volatile (</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno">  210</span>        <span class="stringliteral">&quot;csrrci %0, mstatus, 0x8\n&quot;</span></div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno">  211</span>        : <span class="stringliteral">&quot;=r&quot;</span> (status) :: <span class="stringliteral">&quot;memory&quot;</span></div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno">  212</span>    );</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno">  213</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno">  214</span>    pico_default_asm_volatile (</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno">  215</span>            <span class="stringliteral">&quot;mrs %0, PRIMASK\n&quot;</span></div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno">  216</span>            <span class="stringliteral">&quot;cpsid i&quot;</span></div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno">  217</span>            : <span class="stringliteral">&quot;=r&quot;</span> (status) :: <span class="stringliteral">&quot;memory&quot;</span>);</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno">  218</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno">  219</span>    <span class="keywordflow">return</span> status;</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno">  220</span>}</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno">  221</span> </div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga863cdac424a18c8ebfcc62107a4c2ad2">  227</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga863cdac424a18c8ebfcc62107a4c2ad2">restore_interrupts</a>(uint32_t status) {</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span>    <a class="code hl_function" href="group__pico__platform.html#gac01ec0ae597f7572f8e298fa4f48c8e6">__compiler_memory_barrier</a>();</div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno">  230</span>    <span class="keywordflow">if</span> (status &amp; 0x8) {</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno">  231</span>        riscv_set_csr(mstatus, 8);</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno">  233</span>        riscv_clear_csr(mstatus, 8);</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span>    }</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span>    <a class="code hl_function" href="group__pico__platform.html#gac01ec0ae597f7572f8e298fa4f48c8e6">__compiler_memory_barrier</a>();</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span>    pico_default_asm_volatile (<span class="stringliteral">&quot;msr PRIMASK,%0&quot;</span>::<span class="stringliteral">&quot;r&quot;</span> (status) : <span class="stringliteral">&quot;memory&quot;</span> );</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno">  238</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno">  239</span>}</div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno">  240</span> </div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno"><a class="line" href="group__hardware__sync.html#ga4bb69d1717ab90105ea05b82291fc0c7">  249</a></span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga4bb69d1717ab90105ea05b82291fc0c7">restore_interrupts_from_disabled</a>(uint32_t status) {</div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno">  250</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno">  251</span>    <span class="comment">// on RISC-V this can enable interrupts, but not disable interrupts... which</span></div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno">  252</span>    <span class="comment">// is the common case and doesn&#39;t require a branch</span></div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno">  253</span>    <a class="code hl_function" href="group__pico__platform.html#gac01ec0ae597f7572f8e298fa4f48c8e6">__compiler_memory_barrier</a>();</div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno">  254</span>    riscv_set_csr(mstatus, status &amp; 8);</div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno">  255</span>    <a class="code hl_function" href="group__pico__platform.html#gac01ec0ae597f7572f8e298fa4f48c8e6">__compiler_memory_barrier</a>();</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno">  256</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno">  257</span>    <span class="comment">// on ARM, this behaves the same as restore_interrupts()</span></div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno">  258</span>    pico_default_asm_volatile (<span class="stringliteral">&quot;msr PRIMASK,%0&quot;</span>::<span class="stringliteral">&quot;r&quot;</span> (status) : <span class="stringliteral">&quot;memory&quot;</span> );</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>}</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span> </div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span><span class="preprocessor">#include &quot;hardware/sync/spin_lock.h&quot;</span></div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno">  263</span> </div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span>uint <a class="code hl_function" href="group__hardware__sync.html#ga8f4578aa492d4d37dfbdab5c99ab5b1c">next_striped_spin_lock_num</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span> </div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno">  290</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga50945cb4c33c3263b69e1fce81c474c7">spin_lock_claim</a>(uint lock_num);</div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno">  291</span> </div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno">  301</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga41304e0ee0aed1b5c20b0fd8c2adf9e6">spin_lock_claim_mask</a>(uint32_t lock_num_mask);</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno">  302</span> </div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno">  310</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__sync.html#ga177efc085451e4eabfc726897a59ca57">spin_lock_unclaim</a>(uint lock_num);</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno">  311</span> </div>
<div class="line"><a id="l00318" name="l00318"></a><span class="lineno">  318</span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__sync.html#ga157bccb525bdfd90255490558cbeb9c0">spin_lock_claim_unused</a>(<span class="keywordtype">bool</span> required);</div>
<div class="line"><a id="l00319" name="l00319"></a><span class="lineno">  319</span> </div>
<div class="line"><a id="l00328" name="l00328"></a><span class="lineno">  328</span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__hardware__sync.html#ga9c66da8cbd0916461d6de2af4340ec4f">spin_lock_is_claimed</a>(uint lock_num);</div>
<div class="line"><a id="l00329" name="l00329"></a><span class="lineno">  329</span> </div>
<div class="line"><a id="l00330" name="l00330"></a><span class="lineno">  330</span><span class="comment">// no longer use __mem_fence_acquire here, as it is overkill on cortex M0+</span></div>
<div class="line"><a id="l00331" name="l00331"></a><span class="lineno">  331</span><span class="preprocessor">#if PICO_C_COMPILER_IS_GNU</span></div>
<div class="line"><a id="l00332" name="l00332"></a><span class="lineno">  332</span><span class="preprocessor">#define remove_volatile_cast(t, x) (t)(x)</span></div>
<div class="line"><a id="l00333" name="l00333"></a><span class="lineno">  333</span><span class="preprocessor">#define remove_volatile_cast_no_barrier(t, x) (t)(x)</span></div>
<div class="line"><a id="l00334" name="l00334"></a><span class="lineno">  334</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00335" name="l00335"></a><span class="lineno">  335</span><span class="preprocessor">#define remove_volatile_cast(t, x) ({__compiler_memory_barrier(); Clang_Pragma(&quot;clang diagnostic push&quot;</span>); Clang_Pragma(&quot;clang diagnostic ignored \&quot;-Wcast-qual\&quot;&quot;); (t)(x); Clang_Pragma(&quot;clang diagnostic pop&quot;); })</div>
<div class="line"><a id="l00336" name="l00336"></a><span class="lineno">  336</span><span class="preprocessor">#define remove_volatile_cast_no_barrier(t, x) ({ Clang_Pragma(&quot;clang diagnostic push&quot;</span>); Clang_Pragma(&quot;clang diagnostic ignored \&quot;-Wcast-qual\&quot;&quot;); (t)(x); Clang_Pragma(&quot;clang diagnostic pop&quot;); })</div>
<div class="line"><a id="l00337" name="l00337"></a><span class="lineno">  337</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00338" name="l00338"></a><span class="lineno">  338</span> </div>
<div class="line"><a id="l00339" name="l00339"></a><span class="lineno">  339</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00340" name="l00340"></a><span class="lineno">  340</span>}</div>
<div class="line"><a id="l00341" name="l00341"></a><span class="lineno">  341</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00342" name="l00342"></a><span class="lineno">  342</span> </div>
<div class="line"><a id="l00343" name="l00343"></a><span class="lineno">  343</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="aaddress__mapped_8h_html"><div class="ttname"><a href="address__mapped_8h.html">address_mapped.h</a></div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga157bccb525bdfd90255490558cbeb9c0"><div class="ttname"><a href="group__hardware__sync.html#ga157bccb525bdfd90255490558cbeb9c0">spin_lock_claim_unused</a></div><div class="ttdeci">int spin_lock_claim_unused(bool required)</div><div class="ttdoc">Claim a free spin lock.</div><div class="ttdef"><b>Definition:</b> sync.c:43</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga15ada9cfb92615e5bb05a29aa3fc7ad8"><div class="ttname"><a href="group__hardware__sync.html#ga15ada9cfb92615e5bb05a29aa3fc7ad8">save_and_disable_interrupts</a></div><div class="ttdeci">static __force_inline uint32_t save_and_disable_interrupts(void)</div><div class="ttdoc">Save and disable interrupts.</div><div class="ttdef"><b>Definition:</b> sync.h:206</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga177efc085451e4eabfc726897a59ca57"><div class="ttname"><a href="group__hardware__sync.html#ga177efc085451e4eabfc726897a59ca57">spin_lock_unclaim</a></div><div class="ttdeci">void spin_lock_unclaim(uint lock_num)</div><div class="ttdoc">Mark a spin lock as no longer used.</div><div class="ttdef"><b>Definition:</b> sync.c:37</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga1a9f3cba87fe49a3907a1535b9adfa3f"><div class="ttname"><a href="group__hardware__sync.html#ga1a9f3cba87fe49a3907a1535b9adfa3f">__mem_fence_release</a></div><div class="ttdeci">static __force_inline void __mem_fence_release(void)</div><div class="ttdoc">Release a memory fence.</div><div class="ttdef"><b>Definition:</b> sync.h:189</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga41304e0ee0aed1b5c20b0fd8c2adf9e6"><div class="ttname"><a href="group__hardware__sync.html#ga41304e0ee0aed1b5c20b0fd8c2adf9e6">spin_lock_claim_mask</a></div><div class="ttdeci">void spin_lock_claim_mask(uint32_t lock_num_mask)</div><div class="ttdoc">Mark multiple spin locks as used.</div><div class="ttdef"><b>Definition:</b> sync.c:31</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga486eada32246494118f8273a80ae6856"><div class="ttname"><a href="group__hardware__sync.html#ga486eada32246494118f8273a80ae6856">__sev</a></div><div class="ttdeci">static __force_inline void __sev(void)</div><div class="ttdoc">Insert a SEV instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:90</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga4bb69d1717ab90105ea05b82291fc0c7"><div class="ttname"><a href="group__hardware__sync.html#ga4bb69d1717ab90105ea05b82291fc0c7">restore_interrupts_from_disabled</a></div><div class="ttdeci">static __force_inline void restore_interrupts_from_disabled(uint32_t status)</div><div class="ttdoc">Restore interrupts to a specified state with restricted transitions.</div><div class="ttdef"><b>Definition:</b> sync.h:249</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga50945cb4c33c3263b69e1fce81c474c7"><div class="ttname"><a href="group__hardware__sync.html#ga50945cb4c33c3263b69e1fce81c474c7">spin_lock_claim</a></div><div class="ttdeci">void spin_lock_claim(uint lock_num)</div><div class="ttdoc">Mark a spin lock as used.</div><div class="ttdef"><b>Definition:</b> sync.c:26</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga577b1aba04c5e961c151c2b5d116618d"><div class="ttname"><a href="group__hardware__sync.html#ga577b1aba04c5e961c151c2b5d116618d">__dmb</a></div><div class="ttdeci">static __force_inline void __dmb(void)</div><div class="ttdoc">Insert a DMB instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:132</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga7799a0b9fc6444d463170266392f5fcd"><div class="ttname"><a href="group__hardware__sync.html#ga7799a0b9fc6444d463170266392f5fcd">__wfe</a></div><div class="ttdeci">static __force_inline void __wfe(void)</div><div class="ttdoc">Insert a WFE instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:106</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga863cdac424a18c8ebfcc62107a4c2ad2"><div class="ttname"><a href="group__hardware__sync.html#ga863cdac424a18c8ebfcc62107a4c2ad2">restore_interrupts</a></div><div class="ttdeci">static __force_inline void restore_interrupts(uint32_t status)</div><div class="ttdoc">Restore interrupts to a specified state.</div><div class="ttdef"><b>Definition:</b> sync.h:227</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga8f4578aa492d4d37dfbdab5c99ab5b1c"><div class="ttname"><a href="group__hardware__sync.html#ga8f4578aa492d4d37dfbdab5c99ab5b1c">next_striped_spin_lock_num</a></div><div class="ttdeci">uint next_striped_spin_lock_num(void)</div><div class="ttdoc">Return a spin lock number from the striped range.</div><div class="ttdef"><b>Definition:</b> sync.c:18</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga9442d73d817ec600c67a632edf8c6668"><div class="ttname"><a href="group__hardware__sync.html#ga9442d73d817ec600c67a632edf8c6668">__nop</a></div><div class="ttdeci">static __force_inline void __nop(void)</div><div class="ttdoc">Insert a NOP instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:71</div></div>
<div class="ttc" id="agroup__hardware__sync_html_ga9c66da8cbd0916461d6de2af4340ec4f"><div class="ttname"><a href="group__hardware__sync.html#ga9c66da8cbd0916461d6de2af4340ec4f">spin_lock_is_claimed</a></div><div class="ttdeci">bool spin_lock_is_claimed(uint lock_num)</div><div class="ttdoc">Determine if a spin lock is claimed.</div><div class="ttdef"><b>Definition:</b> sync.c:47</div></div>
<div class="ttc" id="agroup__hardware__sync_html_gaac3457fdba1624e5f45e7f936ad68049"><div class="ttname"><a href="group__hardware__sync.html#gaac3457fdba1624e5f45e7f936ad68049">__mem_fence_acquire</a></div><div class="ttdeci">static __force_inline void __mem_fence_acquire(void)</div><div class="ttdoc">Acquire a memory fence.</div><div class="ttdef"><b>Definition:</b> sync.h:173</div></div>
<div class="ttc" id="agroup__hardware__sync_html_gaaf83973c85c4d0987d34f31ff9590ec5"><div class="ttname"><a href="group__hardware__sync.html#gaaf83973c85c4d0987d34f31ff9590ec5">__wfi</a></div><div class="ttdeci">static __force_inline void __wfi(void)</div><div class="ttdoc">Insert a WFI instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:121</div></div>
<div class="ttc" id="agroup__hardware__sync_html_gae516e592b0d308fe5b032e34109b0057"><div class="ttname"><a href="group__hardware__sync.html#gae516e592b0d308fe5b032e34109b0057">__isb</a></div><div class="ttdeci">static __force_inline void __isb(void)</div><div class="ttdoc">Insert a ISB instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:162</div></div>
<div class="ttc" id="agroup__hardware__sync_html_gaf9544395481cc10fe75df2e8fe58d52a"><div class="ttname"><a href="group__hardware__sync.html#gaf9544395481cc10fe75df2e8fe58d52a">__dsb</a></div><div class="ttdeci">static __force_inline void __dsb(void)</div><div class="ttdoc">Insert a DSB instruction in to the code path.</div><div class="ttdef"><b>Definition:</b> sync.h:147</div></div>
<div class="ttc" id="agroup__pico__platform_html_ga23eadd8d1642fb8fe4600708c36e116a"><div class="ttname"><a href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a></div><div class="ttdeci">#define __force_inline</div><div class="ttdoc">Attribute to force inlining of a function regardless of optimization level.</div><div class="ttdef"><b>Definition:</b> compiler.h:125</div></div>
<div class="ttc" id="agroup__pico__platform_html_gac01ec0ae597f7572f8e298fa4f48c8e6"><div class="ttname"><a href="group__pico__platform.html#gac01ec0ae597f7572f8e298fa4f48c8e6">__compiler_memory_barrier</a></div><div class="ttdeci">static __always_inline void __compiler_memory_barrier(void)</div><div class="ttdoc">Ensure that the compiler does not move memory access across this method call.</div><div class="ttdef"><b>Definition:</b> compiler.h:173</div></div>
<div class="ttc" id="ahazard3_8h_html"><div class="ttname"><a href="hazard3_8h.html">hazard3.h</a></div></div>
<div class="ttc" id="apico_8h_html"><div class="ttname"><a href="pico_8h.html">pico.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>